#ifndef COMMON_TYPES_HPP
#define COMMON_TYPES_HPP

#include <string>

namespace xzt
{
    // 用户
    class UserDataType
    {
    public:
        std::string user_id;
        std::string username;
        std::string password;
        std::string email;
        std::string created_at;
        bool status{true};
    public:
        UserDataType() = default;
        UserDataType(const std::string& username, const std::string& password, const std::string& email)
            : username(username), password(password), email(email) {}
        
        operator bool() const { return !username.empty() && !password.empty() && !email.empty(); }
    };

    // 帖子
    class PostDataType
    {
    public:
        std::string post_id;
        std::string user_id;
        std::string title;
        std::string content;
        std::string created_at;
        size_t likes{0};
    public:
        PostDataType() = default;
        PostDataType(const std::string& user_id, const std::string& title, const std::string& content)
            : user_id(user_id), title(title), content(content) {}

        operator bool() const { return !title.empty() && !content.empty() && !user_id.empty(); }
    };

    // 图片
    class PhotoDataType
    {
    public:
        std::string photo_id;
        std::string user_id;
        std::string title;
        std::string category;
        std::string image_path;
        std::string created_at;
        size_t likes{0};
        std::vector<char> image_binary;  // 图片二进制数据。为了避免字符丢失、乱码没有采用string类型。
    public:
        PhotoDataType() = default;
        PhotoDataType(const std::string& user_id, const std::string& title, const std::string& category, const std::string& image_path, const std::string& created_at)
            : user_id(user_id), title(title), category(category) {}
    
        operator bool() const { return !user_id.empty() && !image_binary.empty(); }
    };

    // 评论
    class CommentDataType
    {
    public:
        std::string comment_id;
        std::string user_id;
        std::string post_id;
        std::string content;
        std::string created_at;
    public:
        CommentDataType() = default;
        CommentDataType(const std::string& user_id, const std::string& post_id, const std::string& content)
            : user_id(user_id), post_id(post_id), content(content) {}

        operator bool() const { return !content.empty() && !user_id.empty() && !post_id.empty(); }
    };

    // 活动事件
    class EventDataType
    {
    public:
        std::string event_id;
        std::string user_id;
        std::string title;
        std::string description;
        std::string location;
        std::string event_date;  // 'YYYY-MM-DD HH:MM:SS'
        std::string created_at;
        bool is_top{false};
        size_t likes{0};
    public:
        EventDataType() = default;
        EventDataType(const std::string& user_id, const std::string& title, const std::string& description, const std::string& location, const std::string& event_date)
            : user_id(user_id), title(title), description(description), location(location), event_date(event_date) {}

        operator bool() const { return !user_id.empty() && !description.empty() && !location.empty() && !title.empty() && !event_date.empty(); }
    };

}



#endif // COMMON_TYPES_HPP